<?php
/**
 * API Interface (not a class or interface)
 * This should not have an visible output, only portable formats like xml
 * json, arrays.  
 * 
 * this may be replaced with proper routing via yaml
 *
 * @author andrew
 * @version 0.0.1
 * @copyright 2012 Coaction Media LLC
 * @package default
 */

/**
 * API Controller as in MVC
 */
session_start();
 
 require_once 'config.php';
 $coreModel = new \Encompass\model\coreModel;

// setup db access
$coreModel->dbConnect();

 // loading utilities class to get url parameters for parsing
$utilities = new \Encompass\Utilities\utilities;
$params = $utilities->getParams();

// load smarty
$smarty = new Smarty_Encompass_Dashboard();

/*
 * based on the function defined in the url, send control to where it needs to
 * go to be handled
 */
switch ($params['function']) {
	
	// handle login and access validation first
	case 'login':
		$auth = new \Encompass\Authorization\auth;
		$auth->tryLogin($params);
		break;
		
	case 'account':
		// show the tab content
		if (isset($params['action'])) {
			$coreModel->account($params, $smarty);
		} else {
			$smarty->display('account.tpl');	
		}
		
		break;
		
	case 'default':
		break;
}


?>